<template>
  <el-dropdown
    size="large"
    type="primary"
    @command="handleCommand"
  >
    <div class="menudown">
      <img
        :src="HeadSRC"
        alt="head"
      >
    </div>
    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item command="Chat">AI Chat</el-dropdown-item>
        <el-dropdown-item command="Picture">AI Draw</el-dropdown-item>
        <el-dropdown-item command="Change">ChangePassword</el-dropdown-item>
        <el-dropdown-item
          divided
          command="LogOut"
        >LogOut</el-dropdown-item>
        <el-dropdown-item disabled>Administrator</el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>

<script setup>
import pinia from "../../store";
import { pageStore } from "../../store/ChatPage";
import router from "../../router";
import { LogOut } from "../../api/api";

const chatstore = pageStore(pinia);
const HeadSRC =
  "https://typora-1312299359.cos.ap-beijing-1.myqcloud.com/icon/bitLogo2.jpg";

function handleCommand(command) {
  switch (command) {
    case "Chat":
      chatstore.updateMode("Chat");
      break;
    case "Picture":
      chatstore.updateMode("Picture");
      break;
    case "LogOut":
      LogOut();
      router.push("/Login");
      break;
    case "Change":
      router.push("/ChangePassword");
      break;
  }
}
</script>

<style scoped>
.menudown {
  position: absolute;
  z-index: 1;
  top: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  overflow: hidden;
}
.menudown img {
  width: 100%;
  height: auto;
}
</style>

    